package Class::Scaffold::Base_TEST;

# $Id: Base_TEST.pm 11275 2006-04-26 10:53:05Z gr $

use strict;
use warnings;
use Error::Hierarchy::Test 'throws2_ok';
use Test::More;


our $VERSION = '0.05';


use base 'Class::Scaffold::Test';


use constant PLAN => 5;


sub run {
    my $self = shift;
    $self->SUPER::run(@_);

    my $obj = $self->make_real_object;
    isa_ok($obj->delegate , 'Class::Scaffold::Environment');
    isa_ok($obj->log      , 'Class::Scaffold::Log');

    throws2_ok { $obj->delegate(1) }
        'Error::Hierarchy::Internal::CustomMessage',
        qr/delegate\(\) is read-only/,
        'exception when trying to set a delegate';

    throws2_ok { $obj->foo }
        'Error::Simple',
        qr/^Undefined subroutine &Class::Scaffold::Base::foo called at/,
        'call to undefined subroutine caught by UNIVERSAL::AUTOLOAD';

    # Undef the existing error. Strangely necessary, otherwise the next
    # ->make_real_object dies with the error message still in $@, although the
    # require() in ->make_real_object should have cleared it on success...

    undef $@;

    throws2_ok { Class::Scaffold::Does::Not::Exist->new }
        'Error::Hierarchy::Internal::CustomMessage',
        qr/Couldn't load package \[Class::Scaffold::Does::Not::Exist\]:/,
        'call to undefined package caught by UNIVERSAL::AUTOLOAD';
}


1;


__END__

{% USE p = PodGenerated %}

=head1 NAME

{% p.package %} - large-scale OOP application support

=head1 SYNOPSIS

    {% p.package %}->new;

=head1 DESCRIPTION

=head1 METHODS

=over 4

{% p.write_methods %}

=back

{% p.write_inheritance %}

{% PROCESS standard_pod %}

=cut

